package com.io.job;


import com.io.config.ConfigurerScheduling;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;



/**
 *
 *
 * @createTime：2020-12-1
 * @author：ls
 *
 */


@Configuration
@Slf4j
public class TimingJob extends ConfigurerScheduling {

    //参数优化 后期读取配置文件
    private Boolean isSwitch=true;

     // 定时的时间cron表达式
    private String cron="0 0 12 * * ?";


    @Override
    protected void processTask() {
        if (isSwitch) {
            log.info("基于接口SchedulingConfigurer的动态定时任务:"
                    + LocalDateTime.now() + "，线程名称：" + Thread.currentThread().getName()
                    + " 线程id：" + Thread.currentThread().getId());
        }
    }

    @Override
    protected String getCron() {
        return cron;
    }
}

